package org.veridiandynamics.server.domain;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Set;

/**
 * User class that is abstract which holds variables for information common to all users.
 *
 */
public abstract class User implements PersistObject, Serializable
{
	protected boolean isSuspended;
	protected String username;
	protected String password;
	protected long id;
	protected Set<Roles> myRoles;

	protected String firstName;
	protected String lastName;
	protected String middleName;
	protected String telephone;
	protected String cell;
	protected String email;
	protected String streetAddress;
	protected int zip;
	protected String city;
	protected String state;
	
	private static final long serialVersionUID = 120L;
	
//	public User(String _username, String _password, Map<String, String> info, List<Role> _roles)
//	{
//		isSuspended = false;
//		username= _username;
//		password=_password;
//		personalInfo=_info;
//		myRoles=_roles;
	
//		fistName = info.get("First Name");
//		middleName = info.get("Middle Name");
//		lastName = info.get("Last name");
//		telephone = info.get("Telephone");
//		cell = info.get("Cell");
//		streetAddress = info.get("Street Address");
//		zip = Integer.parseInt(info.get("Zip"));
//		city = info.get("City");
//		state = info.get("State");
//	}
	
	/**
	 * Returns ID
	 * @return
	 */
	public long getId() {
		return id;
	}

	/**
	 * Sets ID
	 * @param id
	 */
	public void setId(long id) {
		this.id = id;
	}

	/**
	 * Returns first name of user.
	 * @return
	 */
	public String getFirstName() {
		return firstName;
	}

	/**
	 * Sets first name of user.
	 * @param firstName
	 */
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	/**
	 * Returns last name of user.
	 * @return
	 */
	public String getLastName() {
		return lastName;
	}

	/**
	 * Sets last name of user.
	 * @param lastName
	 */
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	/**
	 * Gets middle name of user.
	 * @return
	 */
	public String getMiddleName() {
		return middleName;
	}

	/**
	 * Sets middle name of user.
	 * @param middleName
	 */
	public void setMiddleName(String middleName) {
		this.middleName = middleName;
	}

	/**
	 * Gets telephone number
	 * @return
	 */
	public String getTelephone() {
		return telephone;
	}

	/**
	 * Sets telephone number.
	 * @param telephone
	 */
	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	/**
	 * Gets cell.
	 * @return
	 */
	public String getCell() {
		return cell;
	}

	/**
	 * Sets cell.
	 * @param cell
	 */
	public void setCell(String cell) {
		this.cell = cell;
	}

	/**
	 * Returns email.
	 * @return
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * Sets email.
	 * @param email
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * Gets address.
	 * @return
	 */
	public String getStreetAddress() {
		return streetAddress;
	}

	/**
	 * Sets address.
	 * @param streetAddress
	 */
	public void setStreetAddress(String streetAddress) {
		this.streetAddress = streetAddress;
	}

	/**
	 * Gets zip code.
	 * @return
	 */
	public int getZip() {
		return zip;
	}

	/**
	 * Sets zip code.
	 * @param zip
	 */
	public void setZip(int zip) {
		this.zip = zip;
	}

	/**
	 * Gets city.
	 * @return
	 */
	public String getCity() {
		return city;
	}

	/**
	 * Sets city.
	 * @param city
	 */
	public void setCity(String city) {
		this.city = city;
	}

	/**
	 * Gets state.
	 * @return
	 */
	public String getState() {
		return state;
	}

	/**
	 * Sets state.
	 * @param state
	 */
	public void setState(String state) {
		this.state = state;
	}


	/**
	 * Gets whether or not user is suspsended
	 * @return true if suspended
	 */
	public boolean isSuspended() {
		return isSuspended;
	}

	/**
	 * Sets variable pertaining to user's suspension.
	 * @param isSuspended
	 */
	public void setSuspended(boolean isSuspended) {
		this.isSuspended = isSuspended;
	}

	/**
	 * Returns user name
	 * @return
	 */
	public String getUsername() {
		return username;
	}

	/**
	 * Sets user name
	 * @param username
	 */
	public void setUsername(String username)
	{
		this.username = username;
	}

	/**
	 * Returns password.
	 * @return
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * Sets password.
	 * @param password
	 */
	public void setPassword(String password) {
		this.password = password;
	}
	

	/**
	 * Returns Set of Role objects
	 * @return
	 */
	public Set<Roles> getMyRoles() {
		return myRoles;
	}

	/**
	 * Sets Set of Role objects
	 * @param myRoles
	 */
	public void setMyRoles(Set<Roles> myRoles) {
		this.myRoles = myRoles;
	}
	

	
	/**
	 * Returns first and last name.
	 * @return
	 */
	public String getName()
	{
		return firstName.concat(lastName);
	}

	/**
	 * Writes object.
	 * 
	 * @param outputStream
	 * @throws IOException
	 */
	private void writeObject(ObjectOutputStream outputStream) throws IOException {
		outputStream.defaultWriteObject();
	}
	
	/**
	 * Reads object.
	 * 
	 * @param inputStream
	 * @throws ClassNotFoundException
	 * @throws IOException
	 */
	private void readObject(ObjectInputStream inputStream) throws ClassNotFoundException, IOException {
		inputStream.defaultReadObject();
	}
}
